Skip to content

Conversation

@mat-hek
Copy link
Contributor

@mat-hek mat-hek commented Nov 13, 2025

In some cases, there's generic code that uses the bitstring modifier because it needs to work for both bitstrings and binaries, for example in erl_eval. Currently such code doesn't work even if no actual bitstrings are involved, and this PR attempts to fix it. In other words, this now works:

defmodule Foo do
  def pattern_match(x, s) do
    case x do
      <<a::bitstring-size(s), b::bitstring>> ->
        {a, b}

      _ ->
        :no_match
    end
  end

  def create(y, s) do
    <<y::bitstring-size(s), 123>>
  end
end

Foo.pattern_match(<<234, 123, 2>>, 16)
# => {<<234, 123>>, <<2>>}
Foo.create(<<234, 123, 2>>, 16)
# => <<234, 123, 123>>

TODO:

  • add tests
  • adjust jit.erl

@mat-hek mat-hek force-pushed the mf/upstream-support-aligned-bitstrings branch from d622626 to bb34fe8 Compare November 13, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant